﻿using System;

namespace Wombat.Core.Services.Pattern
{
    internal abstract class PatternDefinition
    {
        internal abstract Guid GetGuid();

        private static readonly char[] CurlyBraces = new[] {'{', '}'};

        public static PatternDefinition GetPatternType(string pattern)
        {
            if (pattern.Equals("*"))
                return new AnythingPatternDefinition();
            if (pattern.StartsWith("{") && pattern.EndsWith("}"))
                return new GuidPatternDefinition(Guid.Parse(pattern.Trim(CurlyBraces)));
            throw new InvalidOperationException(string.Format("Invalid pattern '{0}'.", pattern));
        }
    }
}